CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(launcher)

IF(MSVC)
  ADD_DEFINITIONS(-D_UNICODE -DQT_LARGEFILE_SUPPORT)
ENDIF(MSVC)

# Find out all source files
FILE(GLOB LAUNCHER_CPP_SRC "*.cpp")
FILE(GLOB LAUNCHER_CPP_HEADER "*.h")
FILE(GLOB LAUNCHER_UI_FILES "*.ui")

# Qt settings
FIND_PACKAGE(Qt4 REQUIRED COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
SET(QT_USE_OPENGL TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS} -DUSE_GUI_QT)

QT4_WRAP_CPP(QT_GENERATED_SRC ${LAUNCHER_CPP_HEADER})
QT4_WRAP_UI(QT_GENERATED_UI_SRC ${LAUNCHER_UI_FILES})

SOURCE_GROUP(GeneratedFiles FILES ${QT_GENERATED_SRC} ${QT_GENERATED_UI_SRC})
SOURCE_GROUP(UI FILES ${LAUNCHER_UI_FILES})

INCLUDE_DIRECTORIES(
  ${launcher_SOURCE_DIR}/../../Dependencies/Include
  ${launcher_SOURCE_DIR}/../Framework/
  ${QT_INCLUDE_DIR}
  .)

LINK_DIRECTORIES(
  ${launcher_SOURCE_DIR}/../../bin
  ${launcher_SOURCE_DIR}/../../Dependencies/Lib)

SOURCE_GROUP(GeneratedFiles FILES ${QT_GENERATED_HEADER} ${QT_GENERTATED_SRC})

ADD_EXECUTABLE(launcher
  ${LAUNCHER_CPP_SRC}
  ${LAUNCHER_CPP_HEADER}
  ${QT_GENERATED_SRC}
  ${QT_GENERATED_UI_SRC})

# Setup libraries to link
SET(FrameLibraries freeimage Cg CgGL ${QT_LIBRARIES})

IF(WIN32)
  LIST(APPEND FrameLibraries cgD3D9 GLU32)
ENDIF(WIN32)

IF(LINUX)
  LIST(APPEND FrameLibraries glu)
ENDIF(LINUX)

TARGET_LINK_LIBRARIES(launcher myframework ${FrameLibraries})

SET(EXECUTABLE_OUTPUT_PATH ${GLOBAL_OUTPUT_PATH})
SET(LIBRARY_OUTPUT_PATH ${GLOBAL_OUTPUT_PATH})

IF(MSVC)
  SET_TARGET_PROPERTIES(launcher PROPERTIES PREFIX "../")
  SET_TARGET_PROPERTIES(launcher PROPERTIES IMPORT_PREFIX "../")
ENDIF(MSVC)